package org.gvp.manager.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.gvp.common.annotation.Operation;
import org.gvp.common.annotation.Tag;
import org.gvp.common.constant.BaseController;
import org.gvp.common.http.Result;
import org.gvp.manager.pojo.GatewayRoute;
import org.gvp.manager.service.GatewayRouteService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag("网关路由管理接口")
@RestController
@RequestMapping("/manager/admin/route")
@RequiredArgsConstructor
public class GatewayRouteController implements BaseController<GatewayRoute> {
    private final GatewayRouteService routeService;

    @Operation(value = "添加路由信息", param = "路由信息")
    @PutMapping
    @Override
    public Result<Integer> add(@RequestBody GatewayRoute pojo) {
        return Result.ok(this.routeService.save(pojo));
    }

    @PostMapping
    @Operation(value = "修改路由信息", param = "路由信息")
    @Override
    public Result<Integer> update(@RequestBody GatewayRoute pojo) {
        return Result.ok(this.routeService.edit(pojo));
    }

    @GetMapping("/list")
    @Operation("获取全部路由信息")
    @Override
    public Result<List<GatewayRoute>> queryList() {
        return Result.ok(this.routeService.findList());
    }
}
